package com.asset.service.imp;

import com.asset.pojo.Asset;
import com.asset.service.AssetService;
import com.asset.service.BaseService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class AssetServiceImp extends BaseService implements AssetService {
	
	@Override
	public List<Asset>  listAssetAllPage(String SearchTemp, Integer start,Integer end,Short equipGenre,Short status,
			Date buyTime1,Date buyTime2,Date useTime1,Date useTime2){
		return assetMapper.listAssetAllPage(SearchTemp, start, end, null, equipGenre, status,buyTime1,buyTime2,useTime1,useTime2);
	}
	
	@Override
	public List<Asset> listAll() {
		return assetMapper.listAll();
	}

	@Override
	public boolean insert(Asset asset) {
		try {
			assetMapper.insert(asset);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}

	@Override
	public int updateByPrivateKey(Asset asset) {
		return assetMapper.updateByPrivateKey(asset);
	}
	
	@Override
	public int updateByKey(Asset asset) {
		return assetMapper.updateByKey(asset);
	}

	@Override
	public int delectByPrivateKey(long id) {
		return assetMapper.delectByPrivateKey(id);
	}

	@Override
	public Asset getAssetByPrivateKey(long id) {
		return assetMapper.getAssetByPrivateKey(id);
	}

	@Override
	public List<Asset> listAssetByKeyAndString(Long id, String SearchTemp) {
		return assetMapper.listAsset(id, SearchTemp);
	}

	@Override
	public List<Asset> listPd(String SearchTemp, Integer start,Integer end,Date buyTime1,Date buyTime2,Date useTime1,Date useTime2) {
		
	    return assetMapper.listAssetAllPage(SearchTemp, start, end, (short)1, null, null,buyTime1,buyTime2,useTime1,useTime2);
	}

	@Override
	public List<Asset> listUnPd(String SearchTemp, Integer start,Integer end,Date buyTime1,Date buyTime2,Date useTime1,Date useTime2) {
	    return assetMapper.listAssetAllPage(SearchTemp, start, end, (short)2, null, null,buyTime1,buyTime2,useTime1,useTime2);
	}

	@Override
	public int exitIfPd(int ifPd) {
		return assetMapper.exitIfPd(ifPd);
	}

	@Override
	public Asset getAssetByUsercode(String code) {		
		return assetMapper.getAssetByUsercode(code);
	}

	@Override
	public Asset getAssetByIdentifer(String identifier) {
		return assetMapper.getAssetByIdentifer(identifier);
	}

	@Override
	public Asset getAssetByItCode(String itCode) {
		return assetMapper.getAssetByItCode(itCode);
	}
}
